using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace KNCApp
{
    partial class MainForm
    {
        #region TREND MANAGER
        private void AddTrends(Business.Models.TestPilot pilot)
        {
            System.Windows.Forms.TabPage tp = 
                new System.Windows.Forms.TabPage(pilot.Pilot.FullName);
            GUI.PlotterPage pp = new KNCApp.GUI.PlotterPage();
            tp.Tag = pilot;
            tp.Controls.Add(pp);
            tp.ImageIndex = 0;
            pp.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tcTrends.TabPages.Add(tp);
        }
        private void ShowTrends(Business.Models.TestPilot pilot)
        {
            foreach(TabPage tp in this.tcTrends.TabPages)
            {
                if(tp.Tag != null && ((Business.Models.TestPilot)(tp.Tag)).GetHashCode() == pilot.GetHashCode())
                    this.tcTrends.SelectedTab = tp;
            }
        }

        private void ClearTrends()
        {
            foreach( TabPage tp in this.tcTrends.TabPages)
            {
                if(tp.Tag != null)
                    this.tcTrends.TabPages.Remove(tp);
            }
        }

        private void UpdatePlotter(Business.Models.ChartResult r)
        {
            foreach(System.Windows.Forms.TabPage tp in this.tcTrends.TabPages)
            {
                if(tp.Tag != null && tp.Tag.GetHashCode() == r.TestPilot.GetHashCode())
                {
                    ((GUI.PlotterPage)tp.Controls[0]).UpdatePlotters(r);
                }
            }
        }

        #endregion
    }
}
